Introduction

26 The first decision to be made was the language in which GNAT should be written. GCC is fully written in C, but for technical reasons as well as non-technical ones, it was inconceivable to use anything but Ada for GNAT itself. We started using a relatively small subset of Ada83, and in typical fashion extended the subset whenever new features became implemented. Six months after the coding started in earnest, we were able to bootstrap the compiler, and abandon the commercial compiler we had been using up to that point. As Ada9X features are implemented, we are now able to write GNAT in Ada9X. In fact, the definition of the language depends heavily on hierarchical libraries, and cannot be given except in Ada9X, so that it is natural for the compiler and the environment to use child units throughout.
Figure~#structure#63> shows the overall structure of the GNAT system.
<#2739#>Figure<#2739#>: <#2740#>The structure of GNAT: compiler, binder, runtime.<#2740#>
#figure64#
41 The front-end of the GNAT compiler is thus written in Ada9X. The back-end of the compiler is the back-end of GCC proper, extended to meet the needs of Ada semantics.

The front-end comprises four phases, which communicate by means of a rather compact Abstract Syntax Tree (AST). The implementation details of the AST are hidden by several procedural interfaces that provide access to syntactic and semantic attributes. The layering of the system, and the various levels of abstraction, are the obvious benefits of writing in Ada, in what one might call ``proper'' Ada style.
It is worth mentioning that strictly speaking GNAT does not use a symbol table. Rather, all semantic information concerning program entities is stored in defining occurrences of these entities directy in the AST. The GNAT structures are thus close in spirit to those of DIANA ~[#diana##1###], albeit more compact. It appears that the AST will be adequate to support an ASIS interface~[#asis##1###].

The four phases of the compiler are sketched in figure~#phases#182>.

<#2742#>Figure<#2742#>: <#2743#>Phases of the GNAT compiler.<#2743#>
#figure183#

Subsequent sections describe each of the phases in detail.

GNAT includes three other modules which are not involved in code generation but are an integral part of any Ada compilation system.These are the runtime and tasking executive, the library manager, and the binder.